﻿Imports System.Net.Mail
Imports NENAData
Imports NENAData.LINQ
Imports NENAData.Transactions
Imports NENAData.NENAProvinces
Imports NENAData.NENAMember
Imports NENAData.Payments

Partial Public Class Receipts
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then

            Dim x As New NENATransactions

            'todo: also include fee paid in this screen
            listCompletedTransactions.DataSource = x.GetCompletedTransactions(CType(Session("Member_ID"), Integer))
            listCompletedTransactions.DataBind()
        End If
    End Sub

    Protected Function GetTransactionPaymentID(ByVal strTransactionID_NENA As String) As String
        Dim ntp As NENAPayments = New NENAPayments
        Dim otp As TransactionPayment
        otp = ntp.GetTransactionPayment(Convert.ToInt32(strTransactionID_NENA), Convert.ToInt32(Session("Member_ID")))

        Return otp.TransactionPaymentID.ToString

    End Function

    Protected Function GetFeebyTransactionType(ByVal strType As String) As String
        Select Case strType
            Case "Membership"
                Dim x As New NENAAffiliate
                Dim oAffiliate As Affiliate

                oAffiliate = x.GetAffiliate_byMemberID(CType(Session("Member_ID"), Integer))

                Return "Membership Fee for " & oAffiliate.Affiliate_Full & "(" & oAffiliate.Affiliate_Description & ") is " & String.Format("{0:C}", oAffiliate.Membership_Fee)
            Case Else
                Return "not membership"
        End Select
    End Function

    Protected Sub ListViewReciepts_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
        'Dim oAffiliate As Affiliate
        Dim oNENAAffiliate As New NENAAffiliate

        'oAffiliate = oNENAAffiliate.GetAffiliate_byTransactionID_byMemberID(e.CommandArgument.ToString, CType(Session("Member_ID"), Integer))
        'lblMessage.Text = "fee = " & String.Format("{0:00.00}", oAffiliate.Membership_Fee)

        Select Case e.CommandName
            Case "ViewReciept"
                'lblMessage.Text = "paypal " & e.CommandArgument.ToString
                Response.Redirect("http://membership.nena.ca/paypal/ViewTransactionReciept.aspx?Member_ID=" & Session("Member_ID") & "&TransactionID=" & e.CommandArgument.ToString, False)
            Case Else
        End Select

    End Sub

    Protected Function GetTransactionType(ByVal strTransactionID_NENA As String) As String

        Dim x As New NENAAffiliate
        Dim oAffiliate As Affiliate
        oAffiliate = x.GetAffiliateFromTransactionPayment(strTransactionID_NENA, Convert.ToInt32(Session("Member_ID")))

        Return "Paid Membership Fee to " & oAffiliate.Affiliate_Full & "(" & oAffiliate.Affiliate_Description & ") "

    End Function

    Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCancel.Click
        Response.Redirect("default.aspx")
    End Sub

End Class